/*
 Copyright (C) 2009  Wang Fei (bjwf2000@gmail.com)

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU Generl Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/***************************************************************************************/
/*                                                                                     */
/*  Copyright(c)   .,Ltd                                                               */
/*                                                                                     */
/***************************************************************************************/
/*  file name                                                                          */
/*             notifier.h                                                              */
/*                                                                                     */
/*  version                                                                            */
/*             1.0                                                                     */
/*                                                                                     */
/*  description                                                                        */
/*                                                                                     */
/*                                                                                     */
/*  component                                                                          */
/*                                                                                     */
/*  author                                                                             */
/*             bjwf       bjwf2000@gmail.com                                           */
/*                                                                                     */
/*  histroy                                                                            */
/*             2008-11-23     initial draft                                            */
/***************************************************************************************/
#ifndef __NOTIFIER_H_
#define __NOTIFIER_H_
#include <map>
#include <list>
#include "log.h"
#include "ccni_msg.h"
class CNotifier : public CJob
{
private:
    CCNIMsgPacker _msg;
    list<CClientPtr> _clis;
public:
    bool create()
    {
        return _msg.create();
    }

    void append(CXmlMsg msg)
    {
        _msg.appendmsg(msg);
    }

    bool addNotifiee(CClientPtr c)
    {
        _clis.push_back(c);
        return true;
    }

    void destroy()
    {
        _msg.free();
        _clis.clear();
    }
    int size()
    {
        return _clis.size();
    }
    bool empty()
    {
        return _clis.empty();
    }
    ~CNotifier()
    {
        destroy();
    }
public:

    virtual bool run();

};
#endif /*__NOTIFIER_H_*/
